alert('SceneSelectPlace.js loaded');

var tmp = 0;

function SceneSelectPlace() {

};

SceneSelectPlace.prototype.initialize = function () {
	alert("SceneSelectPlace.initialize()");
	// this function will be called only once when the scene manager show this scene first time
	// initialize the scene controls and styles, and initialize your variables here
	// scene HTML and CSS will be loaded before this function is called
	//DisplayTabCoord();
	
	sf.scene.show('ToolBar');
	
	$('#Dot').sfImage({
		src:'images/Dot2.png'
	});
	
	$('#Dot2').sfImage({
		src:'images/Dot.png'
	});
	
	$('#Dot3').sfImage({
		src:'images/Dot.png'
	});
	
	$('#El01').css("left",ExtractX(1,4)+"px");
	$('#El01').css("top",ExtractY(1,4)+"px");
	
	$('#El02').css("left",ExtractX(3,5)+"px");
	$('#El02').css("top",ExtractY(3,5)+"px");
	
	$('#El03').css("left",ExtractX(4,7)+"px");
	$('#El03').css("top",ExtractY(4,7)+"px");
	
	alert(" **** " + $('#El01').css("left") + " **** ");
	alert(" **** " + $('#El02').css("left") + " **** ");
	alert(" **** " + $('#El02').css("left") + " **** ");
	
};

SceneSelectPlace.prototype.handleShow = function (data) {
	alert("SceneSelectPlace.handleShow()");
	// this function will be called when the scene manager show this scene
};

SceneSelectPlace.prototype.handleHide = function () {
	alert("SceneSelectPlace.handleHide()");
	// this function will be called when the scene manager hide this scene
};

SceneSelectPlace.prototype.handleFocus = function () {
	alert("SceneSelectPlace.handleFocus()");
	// this function will be called when the scene manager focus this scene
};

SceneSelectPlace.prototype.handleBlur = function () {
	alert("SceneSelectPlace.handleBlur()");
	// this function will be called when the scene manager move focus to another scene from this scene
};

SceneSelectPlace.prototype.handleKeyDown = function (keyCode) {
	alert("SceneSelectPlace.handleKeyDown(" + keyCode + ")");
	// TODO : write an key event handler when this scene get focued
	switch (keyCode) {
		case sf.key.LEFT:
			tmp--;
			HandleSelect();
			break;
		case sf.key.RIGHT:
			tmp++;
			HandleSelect();
			break;
		case sf.key.UP:
			break;
		case sf.key.DOWN:
			break;
		case sf.key.ENTER:
			if (tmp == 2){
				sf.scene.hide('SelectPlace');
				sf.scene.show('TestScene1');
				sf.scene.focus('TestScene1');
			}
			break;
		case sf.key.RETURN:
			event.preventDefault();
			sf.scene.hide('SelectPlace');
			sf.scene.show('Menu');
			sf.scene.focus('Menu');
			break;
		default:
			alert("handle default key event, key code(" + keyCode + ")");
			break;
	}
};

function HandleSelect(){
	if (tmp == 0){
		$('#Dot').sfImage({src:'images/Dot2.png'});
		$('#Dot2').sfImage({src:'images/Dot.png'});				
		$('#Dot3').sfImage({src:'images/Dot.png'});
	}else if (tmp == 1){
		$('#Dot').sfImage({src:'images/Dot.png'});
		$('#Dot2').sfImage({src:'images/Dot2.png'});				
		$('#Dot3').sfImage({src:'images/Dot.png'});
	}else if (tmp == 2){
		$('#Dot').sfImage({src:'images/Dot.png'});
		$('#Dot2').sfImage({src:'images/Dot.png'});				
		$('#Dot3').sfImage({src:'images/Dot2.png'});
	}else if (tmp < 0){
		tmp = 2;
		$('#Dot').sfImage({src:'images/Dot.png'});
		$('#Dot2').sfImage({src:'images/Dot.png'});				
		$('#Dot3').sfImage({src:'images/Dot2.png'});
	}else if (tmp > 2){
		tmp = 0;
		$('#Dot').sfImage({src:'images/Dot2.png'});
		$('#Dot2').sfImage({src:'images/Dot.png'});				
		$('#Dot3').sfImage({src:'images/Dot.png'});
	}
}
